#include "QHandler.h"

class DemoHandler : public QHandler
{
    Q_OBJECT
public:
    // 该函数会在后台线程中调用
    void handleMessage(QHandlerMessage *message) Q_DECL_OVERRIDE
    {
        switch (message->what)
        {
            case 1:                
                {
                    // TODO
                    auto arg = message->arg1;
                }
                break;

            default:
                break:
        }
    }
}

void main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    DemoHandler handler;
    auto message = handler.obtainMessage(1);  // 1: 消息类型
    message->arg1 = 3;  // 消息参数
    message->sendToTarget();

    return a.exec();
}